package org.come.mouslisten;

import com.gl.util.Xy2Util;
import org.come.Frame.MsgJframe;
import org.come.Jpanel.MsgJframe2;
import org.come.Jpanel.PetsMsgJpanel;
import org.come.entity.RoleSummoning;
import org.come.until.FormsManagement;
import org.come.until.UserMessUntil;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Objects;

/**
 * 召唤兽信息监听
 * @author admin
 *
 */
public class MsgPetDatilMouslisten implements MouseListener {

    private int index;
    private PetsMsgJpanel petsMsgJpanel;
    private int type;

    public MsgPetDatilMouslisten(int index, PetsMsgJpanel petsMsgJpanel, int type) {
        this.index = index;
        this.petsMsgJpanel = petsMsgJpanel;
        this.type = type;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
    	
        // 左键点击
        if (e.getButton() == MouseEvent.BUTTON1) {
            if(this.type == 1) {
                if (PetsMsgJpanel.roleSummoning == null) {
                    return;
                }
                MsgJframe2.getJframe2().getJapnel2().petMsgsCZ("",PetsMsgJpanel.roleSummoning);
            }
        }
        if (e.getButton() == MouseEvent.BUTTON3) {
        	
        }
    }

    @Override
    public void mousePressed(MouseEvent e) {
        // TODO Auto-generated method stub
//    	System.out.println("点击");
    }

    @Override
    public void mouseReleased(MouseEvent e) {

        // TODO Auto-generated method stub
    }

//    @Override
//    public void mouseEntered(MouseEvent e) {
//    	System.out.println("指上去");
//    	
////    	JLabel s = (JLabel) e.getSource();
//    }

    public void mouseEntered(MouseEvent e) {
        if (PetsMsgJpanel.roleSummoning == null) {
            return;
        }
        RoleSummoning pet = PetsMsgJpanel.roleSummoning;
        RoleSummoning oldpet = null;

        for(RoleSummoning roleSummoning : UserMessUntil.getRoleSummoningList()){
            if(Objects.equals(roleSummoning.getSummoningid(), pet.getSummoningid())){
                oldpet = roleSummoning;
            }
        }
        if(this.type == 1) {
            MsgJframe2.getJframe2().getJapnel2().petMsgsCZ("成长率", pet);
        }else if(this.type == 2) {
            String msg = "气血:"+oldpet.getHp()+"("+pet.getHp()+")";
            MsgJframe2.getJframe2().getJapnel2().petMsgsSW(msg, pet);
        }else if(this.type == 3) {
            String msg = "法力:"+oldpet.getMp()+"("+pet.getMp()+")";
            MsgJframe2.getJframe2().getJapnel2().petMsgsSW(msg, pet);
        }else if(this.type == 4) {
            String msg = "攻击:"+oldpet.getAp()+"("+pet.getAp()+")";
            MsgJframe2.getJframe2().getJapnel2().petMsgsSW(msg, pet);
        }else if(this.type == 5) {
            String msg = "速度:"+oldpet.getSp()+"("+pet.getSp()+")";
            MsgJframe2.getJframe2().getJapnel2().petMsgsSW(msg, pet);
        }
    }

    public void mouseExited(MouseEvent e) {
    	FormsManagement.HideForm(628);
    }
    
    
    
    
    
    
    
}
